package net.apexes.demo.codegen.dslite.qvar;

import java.math.BigDecimal;
import net.apexes.demo.codegen.dslite.entity.Goods;
import net.apexes.demo.codegen.dslite.qvar.base.QEntityBase;
import net.apexes.demo.codegen.entity.enums.GoodsCategory;
import net.apexes.demo.codegen.entity.enums.GoodsType;
import net.wafo.dslite.core.info.ForeignKey;
import net.wafo.dslite.core.info.Index;

import net.wafo.dslite.core.dsl.*;

/**
 * QGoods is a DSLite query type for Goods
 * @see Goods
 */
public class QGoods extends QEntityBase<Goods> {

    public static final QGoods $ = new QGoods("GOODS");

    public final StringColumn goodsBaseId = varchar("GOODS_BASE_ID", 22).field("goodsBaseId").notNull().build();

    public final SimpleColumn<GoodsType> goodsType = varchar(GoodsType.class, "GOODS_TYPE", 1).field("goodsType").notNull().build();

    public final SimpleColumn<GoodsCategory> goodsCategory = varchar(GoodsCategory.class, "GOODS_CATEGORY", 1).field("goodsCategory").notNull().build();

    public final StringColumn barCode = varchar("BAR_CODE", 16).field("barCode").build();

    public final StringColumn skuCode = varchar("SKU_CODE", 22).field("skuCode").build();

    public final NumberColumn<BigDecimal> price = decimal("PRICE", 12, 3).field("price").notNull().build();

    public final NumberColumn<Integer> seqOrder = integer("SEQ_ORDER").field("seqOrder").notNull().build();

    public final SimpleColumn<byte[]> photo = blob("PHOTO").field("photo").build();

    public final StringColumn templateId = varchar("TEMPLATE_ID", 22).field("templateId").notNull().build();

    public class Indexs {

        public final Index constraintIndex4 = index("CONSTRAINT_INDEX_4").column(goodsBaseId).build();

        public final Index ixGoodsSkuCode = index("IX_GOODS_SKU_CODE").column(skuCode).build();

        public final Index primaryKey4 = index("PRIMARY_KEY_4").unique().column(id).build();

    }

    public final Indexs ix = new Indexs();

    public class ForeignKeys {

        public final ForeignKey constraint40 = foreignKey(goodsBaseId, "GOODS_BASE", "ID");

    }

    public final ForeignKeys fk = new ForeignKeys();

    public QGoods(String tableName) {
        super(Goods.class, tableName);
    }

    @Override
    public Goods newEntity() {
        return new Goods();
    }

    @Override
    public Object getFieldValue(Goods entity, String fieldName) {
        switch (fieldName) {
            case "goodsBaseId":
                return entity.getGoodsBaseId();
            case "goodsType":
                return entity.getGoodsType();
            case "goodsCategory":
                return entity.getGoodsCategory();
            case "barCode":
                return entity.getBarCode();
            case "skuCode":
                return entity.getSkuCode();
            case "price":
                return entity.getPrice();
            case "seqOrder":
                return entity.getSeqOrder();
            case "photo":
                return entity.getPhoto();
            case "templateId":
                return entity.getTemplateId();
            default:
                return super.getFieldValue(entity, fieldName);
        }
    }

    @Override
    public void setFieldValue(Goods entity, String fieldName, Object value) {
        switch (fieldName) {
            case "goodsBaseId":
                entity.setGoodsBaseId((java.lang.String) value);
                break;
            case "goodsType":
                entity.setGoodsType((net.apexes.demo.codegen.entity.enums.GoodsType) value);
                break;
            case "goodsCategory":
                entity.setGoodsCategory((net.apexes.demo.codegen.entity.enums.GoodsCategory) value);
                break;
            case "barCode":
                entity.setBarCode((java.lang.String) value);
                break;
            case "skuCode":
                entity.setSkuCode((java.lang.String) value);
                break;
            case "price":
                entity.setPrice((java.math.BigDecimal) value);
                break;
            case "seqOrder":
                entity.setSeqOrder((java.lang.Integer) value);
                break;
            case "photo":
                entity.setPhoto((byte[]) value);
                break;
            case "templateId":
                entity.setTemplateId((java.lang.String) value);
                break;
            default:
                super.setFieldValue(entity, fieldName, value);
                break;
        }
    }

}

